﻿using System;
using Microsoft.SharePoint;

namespace SharePoint.Diagnostics.DemoPackage
{
    /// <summary>
    /// Feature Receiver Demo
    /// </summary>
    [CLSCompliant(false)]
    public class FeatureReceiverTest : SPFeatureReceiver
    {
        /// <summary>
        /// Features the activated.
        /// </summary>
        /// <param name="properties">The properties.</param>
        [CLSCompliant(false)]
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            Trace.LogInformationEvent("SharePointDiagnosticsDemoFeature activated", "SharePointDiagnosticsDemo");

            // Simulate exception:
            Trace.LogError(new Exception("exception"), "SharePointDiagnosticsDemo");
        }

        /// <summary>
        /// Features the deactivating.
        /// </summary>
        /// <param name="properties">The properties.</param>
        [CLSCompliant(false)]
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            Trace.LogInformationEvent("SharePointDiagnosticsDemoFeature deactivated", "SharePointDiagnosticsDemo");
        }

        /// <summary>
        /// Features the installed.
        /// </summary>
        /// <param name="properties">The properties.</param>
        [CLSCompliant(false)]
        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            Trace.LogInformationEvent("SharePointDiagnosticsDemoFeature installed", "SharePointDiagnosticsDemo");
        }

        /// <summary>
        /// Features the uninstalling.
        /// </summary>
        /// <param name="properties">The properties.</param>
        [CLSCompliant(false)]
        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            Trace.LogInformationEvent("SharePointDiagnosticsDemoFeature uninstalled", "SharePointDiagnosticsDemo");
        }
    }
}
